var axios =require("axios");
var bangumiApi = {

	/*番剧推荐*/
	getSlideshow : ()=> {
		return axios.get('http://www.bilibili.com/index/slideshow.json')
      .then(function (data) {
        return data.data;
      })
      .catch(function (err) { console.warn('Error in getSlideshow', err) })
		
	},
	
	/*APP启动图*/
	getBangumi : ()=> {
		return axios.get('http://app.bilibili.com/bangumi/timeline_v2',
		{
			params:{"_device":'iphone',"btype":"2","platform":"ios","type":"json"}
		}
		
		)
      .then(function (data) {
        return data.data;
      })
      .catch(function (err) { console.warn('Error in getBangumi', err) })
		
	},
	/*分类排行*/
	getSortList : (tid, page, pagesize ,order)=> {
		return axios.get('http://api.bilibili.com/list',
		{
			params:{"appver":'2310',"build":"2310","ios":"0","order":order,"page":page,"pagesize":pagesize,"platform":"ios","tid":tid,"type":"json","appkey":"422fd9d7289a1dd9"}
		}
		
		)
      .then(function (data) {
        var sortlist =data.data.list;
		  var new_sortlist=[]
		  for(var key in sortlist){
			  if(key!='num'){
				  new_sortlist[key]=sortlist[key]
			  }
		  }
		  return {list:new_sortlist,pages:data.data.pages};
      })
      .catch(function (err) { console.warn('Error in getSortList', err) })
		
	}

};

export {
	bangumiApi
}
